# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
#     https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
#     https://docs.fastlane.tools/plugins/available-plugins
#

# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane

default_platform(:ios)

platform :ios do
  desc "Description of what the lane does"
  lane :custom_lane do
    # add actions here: https://docs.fastlane.tools/actions
  end

   desc "打包提交appstore"
  lane :appstore do |options|
    build_number = get_build_number(xcodeproj: "HuiZe.xcodeproj")
    version = get_version_number(xcodeproj: "HuiZe.xcodeproj")
    time = Time.new.strftime("%Y%m%d") #获取时间格式
    ipaName = "appstore_#{version}_#{time}.ipa"

    produce(
     username: "179329938@qq.com",# APPle ID
     app_name: "慧择云志愿",#App 名称
     app_identifier: "com.yiqi.hzapp",#App bundle id
     app_version: "1.0",#App 版本
     sku: "1555504181",#App sku
     language: "Simplified Chinese",#App 语言，默认English
   )
  gym(
    clean:true, #打包前clean项目
    workspace: "HuiZe.xcworkspace",
    export_method: "app-store", #导出方式
    scheme:"HuiZe", #scheme
    silent: true, #是否隐藏打包时不需要的信息
    output_directory:"./build/appstore",#输出的位置
    output_name:"#{ipaName}",#输出的包名
    configuration: "Release",#环境
    )
  end

desc "打包到pgy"
  lane :adhoc do |options|
    build_number = get_build_number(xcodeproj: "HuiZe.xcodeproj")
    version = get_version_number(xcodeproj: "HuiZe.xcodeproj")
    time = Time.new.strftime("%Y%m%d") #获取时间格式
    ipaName = "Release_#{version}_#{time}.ipa"
  gym(
    clean:true, #打包前clean项目
    workspace: "HuiZe.xcworkspace",
    export_method: "ad-hoc", #导出方式
    scheme:"HuiZe", #scheme
    silent: true, #是否隐藏打包时不需要的信息
    output_directory:"./build/release",#输出的位置
    output_name:"#{ipaName}",#输出的包名
    configuration: "Release",#环境
    )
  #蒲公英的配置 替换为自己的api_key和user_key
  pgyer(api_key: "44233d0bdd7ab3d0eac427a53f188e46", user_key: "dbda38349b8ea1deccb60aec16b5340b",update_description: options[:desc])
  end

desc "导出debug包"
  lane :debug do |options|
    build_number = get_build_number(xcodeproj: "HuiZe.xcodeproj")
    version = get_version_number(xcodeproj: "HuiZe.xcodeproj")
    time = Time.new.strftime("%Y%m%d") #获取时间格式
    ipaName = "Debug_#{version}_#{time}.ipa"
  gym(
    clean:true, #打包前clean项目
    workspace: "HuiZe.xcworkspace",
    export_method: "development", #导出方式
    scheme:"HuiZe", #scheme
    silent: true, #是否隐藏打包时不需要的信息
    output_directory:"./build/debug",#输出的位置
    output_name:"#{ipaName}",#输出的包名
    configuration: "Debug",#环境
    )
  end
end
